/*
   获取元素对象
   参数可以为元素id -> 返回该对象
   或者标签名      -> 返回该类标签对象数组
   如果获取对象失败 返回空
*/
function gg()
{
	var obj=new Array();
	for(var i=0,j=arguments.length;i<j;i++)
	{
	    ele=arguments[i];
		if(typeof ele=='object')
		return ele;
		if(typeof ele=='string')
		ele=document.getElementById(ele)?document.getElementById(ele):document.getElementsByTagName(ele).length>0?document.getElementsByTagName(ele):false;
		if(j==1)
		return ele;
		obj.push(ele);
	}
	return obj;
}

/*
	搜索框选择表签选项卡	
*/
function chg_tit(n)
	{
		var aA=gg('search_tit').getElementsByTagName('a');
		var aAction=new Array(ROOT+'/Search/search/type/youhui',ROOT+'/Search/search/type/website',ROOT+'/Search/search/type/news',ROOT+'/Search/search/type/tousu');
		for(var i=0,j=aA.length;i<j;i++)
		{
			aA[i].className='';
		}
		aA[n].className='active';
		gg('t_searchform').action=aAction[n];
	}

/*
	滑动标签
*/
Evlon={};
Evlon.createDelegate = function(instance, method)
{
	return function()
	{
		method.apply(instance, arguments);
	}
}
Evlon.Tab = function(tabWnd, elmt, focusClassName, elmtContent, enableHoverSwitch)
{
	this.tabWnd = tabWnd;
	this.elmt = elmt;
	this.focusClassName = focusClassName;
	this.content = elmtContent;
	this.enableHoverSwitch = enableHoverSwitch;
	this._timer = null;

	this.hide = function()
	{
		var re = new RegExp("\\s+" + focusClassName,"ig");
		var className = ' ' +  this.elmt.className.toString();
		this.elmt.className = className.replace(re,'');
		this.content.style.display = 'none';
	}
	this.show = function()
	{
		this.elmt.className += ' ' + focusClassName;
		this.content.style.display = '';
	}
	this.menu_onclick = function()
	{
		this.menu_onmouseout();
		return this.tabWnd.switchTab(this);
	}
			
	this.menu_onmouseover = function()
	{
		window.status = new Date();
		this.menu_onmouseout();
		this._timer = window.setTimeout( Evlon.createDelegate(this.elmt, this.elmt.onclick), 100);
	}
	this.menu_onmouseout = function()
	{
		if(this._timer)
		{
			window.clearTimeout(this._timer);
		}
	}
	this.hide();
	this.elmt.onclick = Evlon.createDelegate(this, this.menu_onclick)
	if(this.enableHoverSwitch)
	{
		this.elmt.onmouseover =  Evlon.createDelegate(this, this.menu_onmouseover)
		this.elmt.onmouseout = Evlon.createDelegate(this, this.menu_onmouseout)
	}
}
		
Evlon.TabWnd = function(idMenu, idDiv, focusClassName, enableHoverSwitch)
{
	this._menu = document.getElementById(idMenu);
	this._content = document.getElementById(idDiv);
	this.tabs = [];
	this.enableHoverSwitch = false | enableHoverSwitch;
		
	this.switchTab = function(newTab)
	{
		this.current.hide();
		this.current = newTab;
		this.current.show();
	}
			
	function getChildren(elmt)
	{
		var elmts = [];
		var e = elmt.firstChild;
		while(e != null)
		{
			if(e.nodeType != 3)
			{
				elmts.push(e);
			}
					
			e = e.nextSibling;
		}
		return elmts;
	}
			
	var childrens = getChildren(this._menu);//.childNodes;
	var contents = getChildren(this._content);//.childNodes;
	if(contents.length != childrens.length)
		throw '菜单和内容数目必须一致！';
	if(childrens.length > 0)
	{
		for(var i = 0; i < childrens.length; ++i)
		{
			var li = childrens[i];
			this.tabs.push(new Evlon.Tab(this, li, focusClassName, contents[i], this.enableHoverSwitch));
		}
		this.current = this.tabs[0];
		this.current.show();
	}
}

//刷新验证码
function fleshVerify(){ 
	//重载验证码
	var timenow = new Date().getTime();
	$("#verifyImg").attr("src" , URL+'/verify/'+timenow);
}
